import Vue from 'vue'
import Vuex from 'vuex'
import { setToken, getToken } from '@/utils/token.js'
import { homeModule } from './modules/homeModule'
import { ReplyModule } from './modules/replyModule'
import { userModule } from './modules/userModule'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    token: getToken('token') || '',
    refresh_token: getToken('refresh_token') || ''
  },
  mutations: {
    getToken (state, value) {
      console.log(value)
      state.token = value.token
      setToken('token', state.token)
      state.refresh_token = value.refresh_token
      setToken('refresh_token', state.refresh_token)
    }
  },
  actions: {},
  modules: {
    home: homeModule,
    reply: ReplyModule,
    user: userModule
  }
})

export default store
